package com.hotel.controller;

import com.hotel.pojo.Orders;
import com.hotel.service.OrderService;
import com.hotel.service.OrdersService;
import com.hotel.vo.PageResult;
import com.hotel.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/orderList")
    public SysResult orderList(PageResult pageResult){
        pageResult = orderService.OrderList(pageResult);
        return SysResult.success(pageResult);
    }
    @DeleteMapping("/{orderId}")
    public SysResult deleteOrder(@PathVariable Integer orderId){
        orderService.deleteOrder(orderId);
        return SysResult.success();
    }
    @PostMapping("/addOrder")
    public SysResult addOrder(@RequestBody Orders order){
        orderService.addOrder(order);
        return SysResult.success();
    }


}
